package com.zmovie.framework.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zmovie.framework.domain.Movie;
import com.zmovie.framework.service.MovieAreaService;
import com.zmovie.framework.service.MovieService;
import com.zmovie.framework.mapper.MovieMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
* @author lenovo
* @description 针对表【movie】的数据库操作Service实现
* @createDate 2023-11-30 12:28:08
*/
@Service
public class MovieServiceImpl extends ServiceImpl<MovieMapper, Movie>
    implements MovieService{
    @Autowired
    private MovieMapper movieMapper;
    @Override
    public Page<Movie> pageMovie(Movie movie, Integer pageNo, Integer pageSize) {
        LambdaQueryWrapper<Movie> wrapper = new LambdaQueryWrapper<>();
        //区域
        wrapper.eq(movie.getAreaId() != null, Movie::getAreaId, movie.getAreaId());
        //年代
        wrapper.eq(movie.getAgeId() != null, Movie::getAgeId, movie.getAgeId());
        //名称
        wrapper.like(movie.getName() != null, Movie::getName, movie.getName());
        wrapper.orderByAsc(Movie::getId);
        Page<Movie> page = new Page<>(pageNo, pageSize);
        return page(page, wrapper);
    }

    @Override
    public List<Movie> listMovieOnScreen(Integer cnt) {
        return movieMapper.listMovieOnScreen(cnt);
    }

    @Override
    public List<Movie> listMovieUpcoming(Integer cnt) {
        return movieMapper.listMovieUpcoming(cnt);
    }

    @Override
    public List<Movie> listMovieClassical(Integer cnt) {
        return movieMapper.listMovieClassical(cnt);
    }

}




